//package com.gzsj.genealogyManagement.people.config;
//
//import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
//import freemarker.template.Configuration;
//import freemarker.template.Template;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
//
//import java.io.ByteArrayOutputStream;
//import java.util.Map;
//
//@org.springframework.context.annotation.Configuration
//public class PdfGenerationService {
//
//    @Autowired
//    private Configuration freemarkerConfig;
//
//    public String generateHtml(Map<String, Object> data) throws Exception {
//        Template template = freemarkerConfig.getTemplate("html/index.ftl");
//        return FreeMarkerTemplateUtils.processTemplateIntoString(template, data);
//    }
//
//
//    public byte[] generatePdf(String htmlContent) throws Exception {
//        try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
//            PdfRendererBuilder builder = new PdfRendererBuilder();
//            builder.withHtmlContent(htmlContent, null); // 第二个参数是资源的基本路径，如果有需要可以设置
//            builder.toStream(os);
//            builder.run();
//            return os.toByteArray();
//        }
//    }
//}